import type { Menu } from "#/entity";
import apiClient from "../../apiClient";

//查询所有菜单
const queryAll = () => apiClient.get<Menu[]>({ url: "/sys/menu/all" });
//查询角色菜单
const rolePermission = (roleId: string) => apiClient.get<number[]>({ url: `/sys/menu/roleAuth/${roleId}` });
//查询用户权限菜单
const userPermission = () => apiClient.get<Menu>({ url: "/sys/menu/userAuth" });
//根据ID获取菜单信息
const findById = (id: string) => apiClient.get<Menu>({ url: `/sys/menu/getRole/${id}` });
//添加菜单
const saveOrUpdate = (data: Menu) => apiClient.post<Menu>({ url: "/sys/menu/saveOrUpdate", data });
//根据ID删除菜单
const deleteById = (id: string) => apiClient.delete({ url: `/sys/menu/del/${id}` });

export default {
	queryAll,
	userPermission,
	rolePermission,
	findById,
	saveOrUpdate,
	deleteById,
};
